package com.nexgo.payment.trans.download;

import android.support.annotation.NonNull;

import com.nexgo.data.entity.RecvData;
import com.nexgo.oaf.apiv3.emv.EmvChannelTypeEnum;
import com.nexgo.oaf.apiv3.emv.EmvTransDataEntity;
import com.nexgo.payment.constrant.TransType;
import com.nexgo.payment.databases.DataSource;
import com.nexgo.payment.entity.TransData;
import com.nexgo.payment.trans.AbsOnlinePresenter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static com.google.common.base.Preconditions.checkNotNull;

/**
 * 响应测试操作业务
 *
 * @author 谭忠扬-YuriTam
 * @time 2017年07月12日
 */
public class TransTestPresenter extends AbsOnlinePresenter implements DownloadTransContract.Presenter {
    private Logger mLog = LoggerFactory.getLogger(TransTestPresenter.class.getSimpleName());

    private DownloadTransContract.View mView;

    public TransTestPresenter(@NonNull DownloadTransContract.View view, @NonNull DataSource repository) {
        super(view, repository);
        mView = checkNotNull(view);
    }

    @Override
    protected TransData getTransData() {
        TransData transData = new TransData();
        transData.setTransType(TransType.TRANS_TEST);
        return transData;
    }

    protected EmvTransDataEntity getEmvTransData(EmvChannelTypeEnum channelType) {
        return null;
    }

    @Override
    protected void onFirstAction() {
        postMainThread(() -> mView.showOnlineProc(mTransData, null));
    }

    @Override
    protected void onTransSuccess(RecvData recvData) {
        postMainThread(() -> mView.showTransSuccess());
    }
}
